package com.newbsd.web.maventest.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.Statement;

import javax.activation.DataSource;
import javax.naming.Context;
import javax.naming.InitialContext;

import com.newbsd.web.maventest.dao.TicketDao1;


/**  
*   
* @author ZHM
* 
*/
public class TicketDaoImpl1 implements TicketDao1{

	 Connection conn = null;
	
	public int updateTicket1(int ticketid) {
		int tnum = 0;
		try {
			Context context = new InitialContext();
			DataSource datasource = (DataSource)context.lookup("java:comp/env/jdbc/maventest");
			conn = ((PreparedStatement) datasource).getConnection();
			PreparedStatement pstmt = 
				conn.prepareStatement("update ticket set ticketnum=(ticketnum-1) where tickedid=?");
			pstmt.setInt(1, ticketid);
			pstmt.execute();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		return tnum;
		
	}

	

	

}
